package LuoGu.搜索.马的遍历;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

//dfs一路到尾， bfs层遍
public class Main {
    static int [] xx = new int []{1,1,-1,-1,2,2,-2,-2};
    static int [] yy = new int []{2,-2,2,-2,1,-1,1,-1};
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int y = s.nextInt()-1;
        int x = s.nextInt()-1;
        int [][] ans = new int[n][m];
        for(int[] i:ans) Arrays.fill(i,-1);
        Queue<int []> queue = new LinkedList<>();
        queue.add(new int []{y,x});
        ans[y][x] = 0;
        while(!queue.isEmpty()){
            int [] temp = queue.poll();
            int ox = temp[1];
            int oy = temp[0];
            for(int i=0;i<8;i++){
                int nx = ox + xx[i];
                int ny = oy + yy[i];
                if(nx>=0&&ny>=0&&nx<m&&ny<n&&ans[ny][nx]==-1){
                    ans[ny][nx] = ans[oy][ox]+1;
                    queue.offer(new int []{ny,nx});
                }
            }
        }

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                System.out.print(String.format("%-5d",ans[i][j]));
            }
            System.out.println();
        }
    }
}
